const mongoose = require("./db")

let usersSchema = new mongoose.Schema({
    username: String, //用户名
    password: String, //密码
    code: String, //验证码
    rid: {
        type: mongoose.Types.ObjectId,
        ref: 'role' //关联role表
    }
})
let usersModel = mongoose.model('users', usersSchema, 'users')

let roleSchema = new mongoose.Schema({
    role_name: String, //角色名
    Iid: {
        type: [mongoose.Types.ObjectId],
        ref: 'IOA' //关联IOA表
    }
})

let roleModel = mongoose.model('role', roleSchema, 'role')

let IOASchema = new mongoose.Schema({
    IOA_name: String, //权限名
    level: Number, //权限等级
    url: String, //权限路径
    Iid: {
        type: mongoose.Types.ObjectId,
        ref: 'IOA' //关联IOA表
    }
})
let IOAModel = mongoose.model('IOA', IOASchema, 'IOA')



<<<<<<< HEAD




let informationSchema=new mongoose.Schema({
    house:Number,
    tai:Boolean,
    room_id:{
        type:mongoose.Types.ObjectId,
        ref:'room_type' //关联房型
    },
    buildingsid:{
        type:mongoose.Types.ObjectId,
        ref: 'buildings' //关联floor表
    },
    floorid: {
        type:mongoose.Types.ObjectId,
        ref: 'floor' //关联floor表
    },

    username:String,
    time:String,
    beizu:String

})

let informationModel = mongoose.model('information', informationSchema, 'information')


=======
//楼栋表
let buildingsSchema=new mongoose. Schema({
    name:String //楼栋名字
})
let buildingsModel = mongoose.model('buildings', buildingsSchema, 'buildings')

//楼层表
let floorSchema=new mongoose.Schema({
    name:String
})
let floorModel = mongoose.model('floor', floorSchema, 'floor')
>>>>>>> 9c3d5db3b70963d3c817a7d1929103739d40f5ad


// 房价
let housemoneySchema=new mongoose.Schema({
    housename:String,
    tai:Boolean,
    room_id:{
        type:mongoose.Types.ObjectId,
        ref:'room_type' //关联房型
    },
    pingtaiid:{
        type:mongoose.Types.ObjectId,
        ref: 'pingtai' //关联floor表
    },
    username:String,
    time:String,
    beizu:String
<<<<<<< HEAD
})
let housemoneyModel = mongoose.model('housemoney', housemoneySchema, 'housemoney')



let pingtaiSchema=new mongoose. Schema({
    name:String
})
let pingtaiModel = mongoose.model('pingtai', pingtaiSchema, 'pingtai')

// 会员


=======

})
let housemoneyModel = mongoose.model('housemoney', housemoneySchema, 'housemoney')

//预约
let reservationSchema = new mongoose.Schema({
    housing_price:Number, //房价
    catered:String, //是否包餐
    time_appointment:{
        type:Date,
        default:Date.now() //预约时间
    },
    Pre_refund_time:{
        type:Date,
        default:Date.now() //预退时间
    },
    status:String, //状态
    room_id:{
        type:mongoose.Types.ObjectId,
        ref:'room_type' //关联房型
    },
    house_id:{
        type:mongoose.Types.ObjectId,
        ref:'housemoney' //关联房价表
    },
    custom_id:{
        type:mongoose.Types.ObjectId,
        ref:'custom' //关联客户表
    },
    number_id:{
        type:mongoose.Types.ObjectId,
        ref:'room_number' //关联房间号表
    }

})
let reservationModel = mongoose.model('reservation', reservationSchema, 'reservation')

//房型
let room_typeSchema = new mongoose.Schema({
    name:String, //房间类型
    img:String, //图片
    Capacity:Number, //容纳人数
    area:Number, //面积
    status:{
        type:Boolean,
        default:true //是否可入住
    }
})
let room_typeModel = mongoose.model('room_type', room_typeSchema, 'room_type')


//客户表
let customSchema = new mongoose.Schema({
    name:String, //姓名
    tell:Number, //电话
    gender:String, //性别
    VIP:String,
    VIP_Level:String, //VIP等级
    document_type:String, //证件类型
    document_number:String, //证件号码
    address:String, //地址
})
let customModel = mongoose.model('custom', customSchema, 'custom')


//寄存表
let depositSchema = new mongoose.Schema({
    deposit_date:{
        type:Date,
        default:Date.now() //寄存时间
    },
    deposit_article:String, //寄存物品
    num:Number, //寄存数量
    deposit_day:String, //寄存天数
    registrant:String, //登记人
    status:String, //状态
    Extract_people:String, //提取人
    Extraction_time:{
        type:Date,
        default:Date.now() //提取时间
    },
    custom_id:{
        type:mongoose.Types.ObjectId,
        ref:'custom' //关联客户表
    }
 })
 let depositModel = mongoose.model('deposit', depositSchema, 'deposit')


 //优惠表
 let youhuiSchema=new mongoose. Schema({
    name:String
})
let youhuiModel = mongoose.model('youhui', youhuiSchema, 'youhui')

//会员管理
>>>>>>> 9c3d5db3b70963d3c817a7d1929103739d40f5ad
let VIPSchema=new mongoose.Schema({
    vipname:String,
    dengji:Number,
    xiaofei1:Number,
    xiaofei2:Number,
    youhuiid:{
        type:mongoose.Types.ObjectId,
        ref: 'youhui' //关联floor表
     },
    room_id:{
       type: [mongoose.Types.ObjectId],
        ref:'room_type' //关联房型
    },
    beizu:String,
    tai:Boolean,
    username:String,
    time:String
})
<<<<<<< HEAD
let VIPModel = mongoose.model('VIP', VIPSchema, 'VIP')




let youhuiSchema=new mongoose. Schema({
    name:String
})
let youhuiModel = mongoose.model('youhui', youhuiSchema, 'youhui')







// 系统日志

let xitongSchema=new mongoose.Schema({
    rizhileiid:{
        type:mongoose.Types.ObjectId,
        ref: 'rizhilei' //关联floor表
     },
    ip:String,
    username:String,
    tel:Number,
    beizu:String,
    tai:Boolean,
    time:String
})
let xitongModel = mongoose.model('xitong', xitongSchema, 'xitong')



let rizhileiSchema=new mongoose.Schema({
    name:String
})
let rizhileiModel = mongoose.model('rizhilei', rizhileiSchema, 'rizhilei')






let buildingsSchema=new mongoose. Schema({
    name:String
})
let buildingsModel = mongoose.model('buildings', buildingsSchema, 'buildings')




let floorSchema=new mongoose.Schema({
    name:String
})
let floorModel = mongoose.model('floor', floorSchema, 'floor')



let room_typeSchema = new mongoose.Schema({
    name:String, //房间类型
    img:String, //图片
    Capacity:Number, //容纳人数
    area:Number, //面积
    status:{
        type:Boolean,
        default:true //是否可入住
    }
})
let room_typeModel = mongoose.model('room_type', room_typeSchema, 'room_type')

=======

let VIPModel = mongoose.model('VIP', VIPSchema, 'VIP')


let room_numberSchema = new mongoose.Schema({
    room_number:String,
})
let room_numberModel = mongoose.model('room_number', room_numberSchema, 'room_number')


>>>>>>> 9c3d5db3b70963d3c817a7d1929103739d40f5ad
module.exports = {
    usersModel,
    roleModel,
    IOAModel,
<<<<<<< HEAD
    buildingsModel,
    floorModel,
    informationModel,
    room_typeModel,
    housemoneyModel,
    pingtaiModel,
    VIPModel,
    youhuiModel,
    xitongModel,
    rizhileiModel
}

=======
    reservationModel,
    room_typeModel,
    customModel,
    depositModel,
    housemoneyModel,
    youhuiModel,
    VIPModel,
    room_numberModel
    
}
>>>>>>> 9c3d5db3b70963d3c817a7d1929103739d40f5ad
